package com.itzxx.huazhun.network

import com.itzxx.huazhun.data.model.CalculationResultsBean
import com.itzxx.huazhun.data.model.DeviceType
import com.itzxx.huazhun.data.model.LoginUser
import com.itzxx.huazhun.data.model.UserAuditInfo
import com.itzxx.huazhun.data.model.UserInfo
import com.itzxx.huazhun.data.model.UserListInfo
import com.itzxx.huazhun.data.model.UserPermissionInfo
import com.itzxx.huazhun.data.model.DevicesBean
import com.itzxx.huazhun.data.model.DevicesChildBean
import com.itzxx.huazhun.data.model.RecordBean
import com.itzxx.huazhun.data.model.RecordCurveAdminDataBean
import com.itzxx.huazhun.data.model.RecordCurveDataBean
import com.itzxx.huazhun.data.model.RecordCurveListDataBean
import com.itzxx.huazhun.data.model.SceneTypeBean
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST

//双重校验锁式-单例 封装NetApiService 方便直接快速调用简单的接口
//val apiService: ApiService by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
//    NetworkApi.INSTANCE.getApi(ApiService::class.java, ApiService.SERVER_URL)
//}

interface ApiService {

    companion object {
        const val SERVER_URL = "http://47.113.196.100:48080/"
    }

    /**
     * 登录
     */
    @POST("app-api/smart/app/user/login")
    suspend fun login(
        @Body body: RequestBody
    ): ApiResponse<LoginUser>

    /**
     * 刷新令牌
     */
    @POST("app-api/smart/app/user/refresh-token")
    fun doRefreshToken(
        @Body body: RequestBody
    ): ApiResponse<LoginUser>

    @POST("app-api/smart/app/user/getTenantIdByName")
    suspend fun getTenantIdByName(@Body body: RequestBody): ApiResponse<String>

    /**
     * 获取登录用户的权限信息
     */
    @GET("app-api/smart/app/user/get-permission-info")
    suspend fun getPermissionInfo(): ApiResponse<UserPermissionInfo>

    /**
     * 获取登录用户的信息
     */
    @GET("app-api/smart/app/user/getUserInfo")
    suspend fun getUserInfo(): ApiResponse<UserInfo>

    /**
     * 用户注册
     */
    @POST("app-api/smart/app/approval/userRegister")
    suspend fun userRegister(@Body body: RequestBody): ApiResponse<Any>

    /**
     * 用户申请记录分页
     */
    @POST("app-api/smart/app/approval/record")
    suspend fun getUserAuditList(@Body body: RequestBody): ApiResponse<UserAuditInfo>

    /**
     * 审批结果
     */
    @POST("app-api/smart/app/approval/result")
    suspend fun doUserAuditHandle(@Body body: RequestBody): ApiResponse<Boolean>

    /**
     * 成员列表分页
     */
    @POST("app-api/smart/app/user/queryMemberListPage")
    suspend fun queryMemberListPage(@Body body: RequestBody): ApiResponse<UserListInfo>

    /**
     * 检测设备列表
     */
    @POST("app-api/smart/app/dev/detectionEquipmentPage")
    suspend fun detectionEquipmentPage(@Body body: RequestBody): ApiResponse<DevicesBean>

    /**
     * 检测设备详情
     */
    @POST("app-api/smart/app/dev/detectionEquipmentInfo")
    suspend fun detectionEquipmentInfo(@Body body: RequestBody): ApiResponse<DevicesChildBean>

    /**
     * 添加检测设备
     */
    @POST("app-api/smart/app/dev/addDetectionEquipment")
    suspend fun addDetectionEquipment(@Body body: RequestBody): ApiResponse<Boolean>

    /**
     * 检测设备类型
     */
    @GET("app-api/smart/app/dev/getEquipmentType")
    suspend fun getEquipmentType(): ApiResponse<ArrayList<DeviceType>>

    /**
     * 探头采集记录列表
     */
    @POST("app-api/smart/app/probe/probeCollectionPage")
    suspend fun probeCollectionPage(@Body body: RequestBody): ApiResponse<RecordBean>

    /**
     * 删除协调器记录
     */
    @POST("app-api/smart/app/probe/delProbeRecord")
    suspend fun delProbeRecordCollection(@Body body: RequestBody): ApiResponse<Boolean>

    /**
     * 上传创建探头采集记录
     */
    @POST("app-api/smart/app/probe/uploadProbeCollection")
    suspend fun uploadProbeCollection(@Body body: RequestBody): ApiResponse<String>


    /**
     * 上传创建探头采集记录关联文件
     */
    @POST("app-api/smart/app/probe/uploadProbeDataUrl")
    suspend fun uploadProbeDataUrl(@Body body: RequestBody): ApiResponse<Boolean>

    /**
     * 上传创建探头采集记录关联文件
     */
    @POST("app-api/smart/app/probe/uploadProbeData")
    suspend fun uploadProbeData(@Body body: RequestBody): ApiResponse<Boolean>

    /**
     * 采集数据曲线
     */
    @POST("app-api/smart/app/equipmentData/queryEquipmentDataCurve")
    suspend fun queryEquipmentDataCurve(@Body body: RequestBody): ApiResponse<RecordCurveDataBean>

    /**
     * 测量数据明细分页
     */
    @POST("app-api/smart/app/equipmentData/queryMeasurementDataDetailsPage")
    suspend fun queryMeasurementDataDetailsPage(@Body body: RequestBody): ApiResponse<RecordCurveListDataBean>

    /**
     * 指定协调器记录关联设备
     */
    @POST("app-api/smart/app/probe/bindProbeDataById")
    suspend fun bindProbeDataById(@Body body: RequestBody): ApiResponse<Boolean>

    /**
     * 获取场景类型
     */
    @GET("admin-api/smart/web/equipmentData/querySceneType")
    suspend fun querySceneType(): ApiResponse<ArrayList<SceneTypeBean>>

    /**
     * 根据场景获取数值
     */
    @POST("admin-api/smart/web/equipmentData/queryNumericalValueByScene")
    suspend fun queryNumericalValueByScene(@Body body: RequestBody): ApiResponse<CalculationResultsBean>


    /**
     * 根据场景获取数值
     */
    @POST("admin-api/smart/web/equipmentData/queryEquipmentDataCurve")
    suspend fun queryAdminEquipmentDataCurve(@Body body: RequestBody): ApiResponse<ArrayList<RecordCurveAdminDataBean>>


}